package com.atguigu03._throws;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ThrowsTst {
//异常的尽头是try-catch
    public void method3() {
        try{
            method1();
        }catch (FileNotFoundException e){

        }catch (IOException e){

        }

}

    public void method2() throws FileNotFoundException, IOException {
        method1();
    }

    public void method1() throws FileNotFoundException, IOException {
        File file = new File( "D : llhello.txt");
        FileInputStream fis = new FileInputStream(file);//可能报FileNotFoundException
        int data = fis.read();//可能报IOException
        while (data != -1) {
            System.out.print((char) data);
            data = fis.read(); //可能报IOException
        }
        fis.close(); //可能报I0Exception
    }

}
